<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
    <style>
        .box {
            position: absolute;
            top:100px;
            left:0;
            width: 100px;
            height: 100px;
            background-color: pink;
        }
    </style>
</head>
<body>
<!--   num+=5;
box.style.left = num + "px";

   leader = leader  + (target - leader ) / 10



   leader 初始 0
   target 结束位置  100
   leader = 10;   步长  10

            19          19-->
<button id="btn">开始</button>
<div class="box" id="bOX"></div>
</body>
</html>
<script>
    var btn = document.getElementById("btn");
    var box = document.getElementById("bOX");
    var timer = null;
    var leader = 0;
    var target = 500;
    btn.onclick = function() {
        setInterval(function(){
            leader = leader + (target - leader )/10;
            box.style.left = leader + "px";
        },30)
    }
</script>